Link with winmm.lib to make it work.
For Dev-cpp go Project>>Project option>>Parameters>>Add library>>libwinmm.a

This snippet opens the door of the CD-ROM. 

==========================================================


#include <iostream>
#include <windows.h> // Sleep()
#include <mmsystem.h> // mciSendString()

using namespace std;

int main()
{
mciSendString("open CDAudio", NULL, 0, NULL);
mciSendString("set CDAudio door open", NULL, 0, NULL);//Open the door
Sleep(1000);
mciSendString("set CDAudio door closed", NULL, 0, NULL);//Close the door
mciSendString("close CDAudio", NULL, 0, NULL);
return 0;
}